package com.thingple.usb.manager;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbAccessory;
import android.hardware.usb.UsbManager;


public class UsbManagerWrapper {

    private static UsbDeviceManager ins;

    public static void init(Context ctx) throws Exception {
        ins = new UsbDeviceManagerImpl(ctx);
    }

    public static UsbDeviceManager getDeviceManager() {
        return ins;
    }
    public static void requestPermission(Context ctx, UsbManager usbManager, UsbAccessory device) {
        Intent intent = new Intent(UsbDeviceManager.ACTION_USB_PERMISSION);
        PendingIntent permissionIntent = PendingIntent.getBroadcast(
                ctx,
                0,
                intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        usbManager.requestPermission(device, permissionIntent);
    }
}
